//区分类型
var distinguishs=sessionStorage.getItem("supplementPlatform")
var supplementmemberid=sessionStorage.getItem("supplementmemberid")
var supplementcustomerid=sessionStorage.getItem("supplementcustomerid")
var dataalls=""
var verifications=''
var stare=sessionStorage.getItem("stare")
//验证是普通会员还是认证会员
verification()
function verification(){
    $.ajax({
        url:root.orderInter.getMemberById,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        async:false,
        data:{
            "memberId":supplementmemberid,

        },
        success: function (data) {
            /**
             * 账户类型：10:签约用户；20:普通用户;30认证用户
             */
            if(data.data!=null){
                verifications=data.data.accountType
            }
        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    });
}

distinguish()
function distinguish() {
    //普通客户
    console.log(distinguishs)
    console.log(verifications)
    if(distinguishs==10){
        if(verifications==20){
            $("#invoice2").removeAttr("onclick")
            $("#invoice2").attr("style","color: rgb(255, 255, 255);background-color: rgb(220 214 214);border-color: rgb(221 224 228);")
            $("#invoice").removeAttr("onclick")
            //普通发票
            $("#ordinaryInvoice").css({
                display: "flex"
            });
            //签约普通发票-
            $("#signUp_ordinaryInvoice").css({
                display: "none"
            });
            //签约的纳税人识别码
            $("#IdentificationCodeall").css({
                display: "none"
            });
            //增值税专用发票
            $("#VATInvoice").css({
                display: "none"
            });
        }else {
            //普通发票
            $("#ordinaryInvoice").css({
                display: "flex"
            });
            //签约普通发票-
            $("#signUp_ordinaryInvoice").css({
                display: "none"
            });
            //签约的纳税人识别码
            $("#IdentificationCodeall").css({
                display: "none"
            });
            //增值税专用发票
            $("#VATInvoice").css({
                display: "none"
            });

            $("#reg_address").removeAttr("readonly")
            $("#reg_telephone").removeAttr("readonly")
            $("#open_account_bank").removeAttr("readonly")
            $("#bank_account").removeAttr("readonly")
            $("#reg_address").removeClass('colorValue')
            $("#reg_telephone").removeClass('colorValue')
            $("#open_account_bank").removeClass('colorValue')
            $("#bank_account").removeClass('colorValue')
        }

    }else {
        //对接和签约

        //签约普通发票-
        $("#signUp_ordinaryInvoice").css({
            display: "flex"
        });
        //签约的纳税人识别码
        $("#IdentificationCodeall").css({
            display: "flex"
        });
        //普通发票
        $("#ordinaryInvoice").css({
            display: "none"
        });


    }
    queryInvoiceInfoByMemberId()

    getInvoiceAddress()


}
/*获取邮寄区域*/
discountdatas(123)
function discountdatas (val) {
    if(val==123){
        //初始化 省
        var user_data = {
            level: '101',
        }
        var succCallBack = function (data, status, response) {
            console.log(data)
            if(data.errorCode=="0"){
                var tab_data=data.list;
                if(tab_data==''){
                    cer+='<option value=""></option>'
                    $("#getProvinces").html(cer);
                }else{
                    console.log("1111111111111222222222")
                    var cer="<option value='' disabled='disabled' data-id='' selected>请选择邮寄区域</option>"
                    for(var i=0; i<tab_data.length; i++){
                        cer+='<option value="'+tab_data[i].code+'"  data-id="'+tab_data[i].address_id+'">'+tab_data[i].name+'</option>'
                    }
                    $("#getProvinces").html(cer);
                    getInvoiceAddress()
                }
            }
        };
        web.doAjax(root.publics.getLowerAddress,'post',user_data, succCallBack);
    }else if(val==1){
        //市
        var cer5="<option value='' data-id=''>请选择邮寄区域</option>"
        $("#getAreas").html(cer5);
        //四级地址隐藏
        $("#getCounty").html(cer5);
        $("#getCounty").css({
            display: "none"
        });
        var special=$('#getProvinces').val()
        if(special==""){
            var cer="<option value='' data-id=''>请选择邮寄区域</option>"
            $("#getCitys").html(cer);
        }else {
            var user_data = {
                level: '102',
                parentCode:special
            }
            var succCallBack = function (data, status, response) {
                if(data.errorCode=="0"){
                    var tab_data=data.list;
                    if(tab_data==''){
                        cer+='<option value=""></option>'
                        $("#getCitys").html(cer);
                    }else{
                        var cer="<option value='' disabled='disabled' data-id='' selected>请选择邮寄区域</option>"
                        for(var i=0; i<tab_data.length; i++){
                            cer+='<option value="'+tab_data[i].code+'" data-id="'+tab_data[i].address_id+'">'+tab_data[i].name+'</option>'
                        }
                        $("#getCitys").html(cer);
                    }
                }
            };
            web.doAjax(root.publics.getLowerAddress,'post',user_data, succCallBack);
        }

    }else if(val==2){
        //区
        var special=$('#getCitys').val()
        if(special==""){
            var cer="<option value='' data-id=''>请选择邮寄区域</option>"
            $("#getAreas").html(cer);
        }else {
            var user_data = {
                level: '103',
                parentCode:special
            }
            var succCallBack = function (data, status, response) {
                if(data.errorCode=="0"){
                    var tab_data=data.list;
                    if(tab_data==''){
                        cer+='<option value=""></option>'
                        $("#getAreas").html(cer);
                    }else{
                        var cer="<option value='' disabled='disabled' data-id='' selected>请选择邮寄区域</option>"
                        for(var i=0; i<tab_data.length; i++){
                            cer+='<option value="'+tab_data[i].code+'"  data-id="'+tab_data[i].address_id+'">'+tab_data[i].name+'</option>'
                        }
                        $("#getAreas").html(cer);
                    }
                }
            };
            web.doAjax(root.publics.getLowerAddress,'post',user_data, succCallBack);
        }
    }else if(val==3){
        //县
        var special=$('#getAreas').val()
        if(special==""){
            var cer="<option value='' data-id=''>请选择邮寄区域</option>"
            $("#getCounty").html(cer);
        }else {
            var user_data = {
                level: '104',
                parentCode:special
            }
            var succCallBack = function (data, status, response) {
                if(data.errorCode=="0"){
                    var tab_data=data.list;
                    console.log(tab_data)
                    if(tab_data==''){
                        $("#getCounty").css({
                            display: "none"
                        });
                        cer+='<option value=""></option>'
                        $("#getCounty").html(cer);

                    }else{
                        $("#getCounty").css({
                            display: "inline"
                        });
                        var cer="<option value='' disabled='disabled' data-id='' selected>请选择邮寄区域</option>"
                        for(var i=0; i<tab_data.length; i++){
                            cer+='<option value="'+tab_data[i].code+'"  data-id="'+tab_data[i].address_id+'">'+tab_data[i].name+'</option>'
                        }
                        $("#getCounty").html(cer);
                    }
                }
            };
            web.doAjax(root.publics.getLowerAddress,'post',user_data, succCallBack);
        }
    }
}
//获取发票信息
function queryInvoiceInfoByMemberId() {
    var invoiceType=""
    if($("#default").val()==100){
        invoiceType=10
    }else {
        invoiceType=20
    }
    $.ajax({
        url:root.orderInter.queryInvoiceInfoByMemberId,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        data:{
            "memberId":supplementmemberid,
            "invoiceType":invoiceType,
            "customerId":supplementcustomerid,

        },
        success: function (data) {
            var invoicedata=data.data
            if(distinguishs==10){
                //普通发票信息
                if($("#default").val()==100){
                    //普通发票
                    dataalls=invoicedata[0].company_name

                        if(invoicedata[0].company_name=="个人"){
                            $("#addInvoice").css({
                                display: "inline"
                            });
                            $(".addInvoice").css({
                                display: "none"
                            });
                        }else {
                            $("#addInvoice").css({
                                display: "none"
                            });
                            $("#InvoiceTitles").css({
                                display: "inline"
                            });
                            $("#IdentificationCodes").css({
                                display: "none"
                            });
                            $("#topicName2").val(invoicedata[0].company_name)
                            $("#taxpayer_code").val(invoicedata[0].taxpayer_code)
                            $("#crm_invoice_ids").val(invoicedata[0].crm_invoice_id)
                        }


                }else {
                    //增值税发票
                    if(invoicedata!="" && invoicedata!=null){
                        $("#crm_invoice_id").val(invoicedata[0].crm_invoice_id)
                        $("#company_name").val(invoicedata[0].company_name)
                        $("#taxpayer_codes").val(invoicedata[0].taxpayer_code)
                        $("#reg_address").val(invoicedata[0].reg_address)
                        $("#reg_telephone").val(invoicedata[0].reg_telephone)
                        $("#open_account_bank").val(invoicedata[0].open_account_bank)
                        $("#bank_account").val(invoicedata[0].bank_account)
                    }
                }

            }else {
                //签约对接
                if($("#default").val()==100){
                    var invoicetables=""
                    for (var i=0;i<invoicedata.length;i++) {
                        invoicetables+=' <tr >\n' +
                            '                                <td class="col-4-1 text-l">\n' +
                            '                                    <div class="row ml-10">\n' +
                            '                                        <input type="text" style="width: 264px;margin-left: 119px;" class="radius curr2" data-id="'+invoicedata[i].crm_invoice_id+'" id="rises" name="couponName" onclick="styles2(this)" placeholder="请输入新增单位发票抬头" value="'+invoicedata[i].company_name+'" autocomplete="off" readonly>\n' +
                            '                                       <input style="display: none" value="'+invoicedata[i].taxpayer_code+'">\n' +
                            '                                    </div>\n' +
                            '                                </td>\n' +
                            '                            </tr>'
                    }
                    $("#tableli").html(invoicetables)
                    //默认第一条数据选中
                    var dataall=$("#tableli").children()[0]
                    var inputdata=$(dataall).children().children().children()[0]
                    $(inputdata).removeClass('curr2')
                    $(inputdata).addClass('curr')
                    $("#IdentificationCode").html($(dataall).children().children().children()[1].value)
                }else {

                    //增值税发票
                    if(invoicedata!="" && invoicedata!=null){
                        if(invoicedata.length==1){
                            //切换发票
                            $("#switchInvoices").css({
                                display: "none"
                            });
                        }else {
                            //切换发票
                            $("#switchInvoices").css({
                                display: "initial"
                            });
                        }
                        $("#ids").val(invoicedata[0].id)
                        $("#company_name").val(invoicedata[0].company_name)
                        $("#taxpayer_codes").val(invoicedata[0].taxpayer_code)
                        $("#reg_address").val(invoicedata[0].reg_address)
                        $("#reg_telephone").val(invoicedata[0].reg_telephone)
                        $("#open_account_bank").val(invoicedata[0].open_account_bank)
                        $("#bank_account").val(invoicedata[0].bank_account)

                    }else {
                        $("#switchInvoices").css({
                            display: "none"
                        });
                    }
                }

            }



        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    });

}


//新增单位发票
function addInvoice() {
    $("#addInvoice").css({
        display: "none"
    });
    $(".addInvoice").css({
        display: "inline"
    });
}

//普通发票抬头样式切换
function styles(val) {
    if(val==1){
        //高亮显示
        $("#topicName2").removeClass('curr');
        $("#topicName2").addClass('curr2');

        $("#topicName").removeClass('curr2');
        $("#topicName").addClass('curr');

        //隐藏
        if(dataalls=="个人"){
            $("#addInvoice").css({
                display: "inline"
            });
            $(".addInvoice").css({
                display: "none"
            });
        }else {
            $("#addInvoice").css({
                display: "none"
            });
            $("#InvoiceTitles").css({
                display: "inline"
            });
            $("#IdentificationCodes").css({
                display: "none"
            });
        }

    }else {
        //高亮显示
        $("#topicName").removeClass('curr');
        $("#topicName").addClass('curr2');

        $("#topicName2").removeClass('curr2');
        $("#topicName2").addClass('curr');

        $("#IdentificationCodes").css({
            display: "inline"
        });

    }

}
//签约发票抬头样式切换
function styles2(val) {
    //高亮显示
    $(val).removeClass('curr2')
    $(val).addClass('curr');
    $(val).parent().parent().parent().siblings().children().children().children().removeClass('curr')
    $(val).parent().parent().parent().siblings().children().children().children().addClass('curr2');
    //纳税人识别码
    $("#IdentificationCode").html($(val).next().val())
}
//切换发票
function switchs(val) {
    console.log(distinguishs)

    if(distinguishs==10){
        if(val==1){
            /*普通发票*/
            $("#ordinaryInvoice").css({
                display: "flex"
            });
            $("#VATInvoice").css({
                display: "none"
            });
            $("#invoice").attr("style","color: rgb(255, 255, 255);background-color: rgb(74, 144, 226);border-color: rgb(74, 144, 226);")
            $("#invoice2").removeAttr("style")
            //调用发票详情接口区分当前发票
            $("#default").val(100)
            //默认发票第一条选中
            $("#topicName2").removeClass('curr');
            $("#topicName2").addClass('curr2');

            $("#topicName").removeClass('curr2');
            $("#topicName").addClass('curr');

            queryInvoiceInfoByMemberId()
        }else {
            /*增值税专用发票*/
            $("#VATInvoice").css({
                display: "flex"
            });
            $("#ordinaryInvoice").css({
                display: "none"
            });
            $("#invoice").removeAttr("style")
            $("#invoice2").attr("style","color: rgb(255, 255, 255);background-color: rgb(74, 144, 226);border-color: rgb(74, 144, 226);")
            //调用发票详情接口区分当前发票
            $("#default").val(200)
            queryInvoiceInfoByMemberId()
        }
    }else {
        if(val==1){
            /*普通发票*/
            $("#signUp_ordinaryInvoice").css({
                display: "flex"
            });
            $("#IdentificationCodeall").css({
                display: "flex"
            });
            $("#tableli").css({
                display: "revert"
            });
            $("#VATInvoice").css({
                display: "none"
            });
            $("#invoice").attr("style","color: rgb(255, 255, 255);background-color: rgb(74, 144, 226);border-color: rgb(74, 144, 226);")
            $("#invoice2").removeAttr("style")
            //调用发票详情接口区分当前发票
            $("#default").val(100)
            queryInvoiceInfoByMemberId()
        }else {
            /*增值税专用发票*/
            $("#VATInvoice").css({
                display: "flex"
            });
            $("#IdentificationCodeall").css({
                display: "none"
            });
            $("#tableli").css({
                display: "none"
            });
            $("#signUp_ordinaryInvoice").css({
                display: "none"
            });
            $("#invoice").removeAttr("style")
            $("#invoice2").attr("style","color: rgb(255, 255, 255);background-color: rgb(74, 144, 226);border-color: rgb(74, 144, 226);")
            //调用发票详情接口区分当前发票
            $("#default").val(200)
            queryInvoiceInfoByMemberId()
        }
    }


}
//切换发票
function switchInvoice() {
    $("#switchInvoice").modal("show")
    $.ajax({
        url:root.orderInter.queryInvoiceInfoByMemberId,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        data:{
            "memberId":supplementmemberid,
            "invoiceType":20,
            "customerId":supplementcustomerid,

        },
        success: function (data) {
            var datas=data.data
            var switchInvoicedata=""
            console.log($("#ids").val())
            for (var i=0;i<datas.length;i++) {
                if($("#ids").val()==datas[i].id){
                    switchInvoicedata += '<tr>' +
                        '                            <td class="col-4-1 text-l" style="width: 10%;"><input style="margin-left: 73%;" checked   type="radio" name="radios" ></td>' +
                        '                               <td class="col-4-1 text-l">' +
                        '                               <span >单位名称：</span><span>'+datas[i].company_name+'</span>' +
                        '                               <br><span>纳税人识别码：</span><span>'+datas[i].taxpayer_code+'</span>' +
                        '                               <br><span>注册地址：</span><span>'+datas[i].reg_address+'</span>' +
                        '                               <br><span>注册电话：</span><span>'+datas[i].reg_telephone+'</span>' +
                        '                               <br><span>开户银行：</span><span>'+datas[i].open_account_bank+'</span>' +
                        '                               <br><span>银行账户：</span><span>'+datas[i].bank_account+'</span>' +
                        '                               <br><span style="display: none">'+datas[i].crm_invoice_id+'</span>' +
                        '                               <br><span style="display: none">'+datas[i].id+'</span></td>' +
                        '                    </tr>'
                }else {
                    switchInvoicedata += '<tr>' +
                        '                            <td class="col-4-1 text-l" style="width: 10%;"><input style="margin-left: 73%;"  type="radio" name="radios" ></td>' +
                        '                               <td class="col-4-1 text-l">' +
                        '                               <span >单位名称：</span><span>'+datas[i].company_name+'</span>' +
                        '                               <br><span>纳税人识别码：</span><span>'+datas[i].taxpayer_code+'</span>' +
                        '                               <br><span>注册地址：</span><span>'+datas[i].reg_address+'</span>' +
                        '                               <br><span>注册电话：</span><span>'+datas[i].reg_telephone+'</span>' +
                        '                               <br><span>开户银行：</span><span>'+datas[i].open_account_bank+'</span>' +
                        '                               <br><span>银行账户：</span><span>'+datas[i].bank_account+'</span>' +
                        '                               <br><span style="display: none">'+datas[i].crm_invoice_id+'</span>' +
                        '                               <br><span style="display: none">'+datas[i].id+'</span></td>' +
                        '                    </tr>'
                }

            }
            $("#switchInvoicedata").html(switchInvoicedata);

        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    });
}
//切换发票取消
function close_switchInvoice() {
    $("#switchInvoice").modal("hide")
}
//切换发票确认
function switchInvoiceadd() {
    var radiosdata =$('input:radio[name="radios"]:checked')
    var information=$(radiosdata).parent().parent().children()[1]
    console.log($(information).children())
    $("#switchInvoice").modal("hide")
    //增值税发票信息
    $("#company_name").val($(information).children()[1].innerHTML)
    $("#taxpayer_codes").val($(information).children()[4].innerHTML)
    $("#reg_address").val($(information).children()[7].innerHTML)
    $("#reg_telephone").val($(information).children()[10].innerHTML)
    $("#open_account_bank").val($(information).children()[13].innerHTML)
    $("#bank_account").val($(information).children()[16].innerHTML)
    $("#crm_invoice_id").val($(information).children()[18].innerHTML)
    $("#ids").val($(information).children()[20].innerHTML)
}

function getInvoiceAddress() {
    $.ajax({
        url:root.orderInter.getInvoiceAddress,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        data:{
            "memberId":supplementmemberid,

        },
        success: function (data) {
            if(data.data!=null && data.data!="" ){
                $("#getProvinces option:selected").val(data.data.provinceCode)
                $("#getProvinces option:selected").attr("data-id",data.data.provinceId)
                $("#getProvinces option:selected").html(data.data.provinceName)

                $("#getCitys option:selected").val(data.data.cityCode)
                $("#getCitys option:selected").attr("data-id",data.data.cityId)
                $("#getCitys option:selected").html(data.data.cityName)

                $("#getAreas option:selected").val(data.data.districtCode)
                $("#getAreas option:selected").attr("data-id",data.data.districtId)
                $("#getAreas option:selected").html(data.data.districtName)

                if(data.data.streetName!="" && data.data.streetName!=null){
                    $("#getCounty").css({
                        display: "inline"
                    });
                    $("#getCounty option:selected").val(data.data.streetCode)
                    $("#getCounty option:selected").attr("data-id",data.data.streetId)
                    $("#getCounty option:selected").html(data.data.streetName)

                }
            $("#detailAddress").val(data.data.detailAddress)
                $("#linkman").val(data.data.linkman)
                $("#officePhone").val(data.data.officePhone)


            }


        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    });
}
//提交信息
function submitInformation() {

    var informationdata={}
            if($("#default").val()==100){
                var invoice_titles=""//发票抬头
                var taxpayer_identify_nums=''//纳税人识别号
                var crm_invoice_ids=""//开票客户编码
                if(distinguishs==10){
                    invoice_titles=$("#ordinaryInvoice").find('.curr').val()
                    if($("#ordinaryInvoice").find('.curr').val()=='个人'){
                        taxpayer_identify_nums=""
                    }else {
                        taxpayer_identify_nums=$("#taxpayer_code").val()
                    }

                    crm_invoice_ids=$("#crm_invoice_ids").val()
                }else {
                    invoice_titles= $("#tableli").find('.curr').val()
                    taxpayer_identify_nums=$("#IdentificationCode").html()
                    crm_invoice_ids=$("#tableli").find('.curr').attr('data-id')
                }
                if(invoice_titles==""){
                    $.Huimodalalert('请填写发票抬头',2000);
                    return false;
                }
                if(invoice_titles.length>50){
                    $.Huimodalalert('发票抬头最大长度50',2000);
                    return false;
                }
                var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                if(pattern.test(invoice_titles)){
                    $.Huimodalalert('发票抬头不能输入特殊字符',2000);
                    return false;
                }

                if(distinguishs==10){
                if(invoice_titles!='个人'){
                    if(taxpayer_identify_nums==""){
                        $.Huimodalalert('请填写纳税人识别码',2000);
                        return false;
                    }
                    if(taxpayer_identify_nums.length>20){
                        $.Huimodalalert('纳税人识别码最大长度20',2000);
                        return false;
                    }
                    /*var regNumber = /\d+/; //验证0-9的任意数字最少出现1次。
                    var regString = /[a-zA-Z]+/; //验证大小写26个字母任意字母最少出现1次。*/
                    var regNumber = /.*[\u4e00-\u9fa5]+.*$/;
                    var regString = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                    if (regNumber.test(taxpayer_identify_nums) || regString.test(taxpayer_identify_nums)) {
                        $.Huimodalalert('纳税人识别码只能输入字母和数字',2000);
                        return false;
                    }

                }
                }
                if($("#getProvinces option:selected").attr("data-id")==""){
                    $.Huimodalalert('请填写邮寄区域',2000);
                    return false;
                }
                if($("#getCitys option:selected").attr("data-id")==""){
                    $.Huimodalalert('请填写邮寄区域',2000);
                    return false;
                }
                if($("#getAreas option:selected").attr("data-id")==""){
                    $.Huimodalalert('请填写邮寄区域',2000);
                    return false;
                }
                if($("#getCounty").css("display")!="none"){
                    if($("#getCounty option:selected").attr("data-id")==""){
                        $.Huimodalalert('请填写邮寄区域',2000);
                        return false;
                    }
                }
                if($("#detailAddress").val()==""){
                    $.Huimodalalert('请填写详细地址',2000);
                    return false;
                }
                if($("#detailAddress").val().length>50){
                    $.Huimodalalert('详细地址最大长度50',2000);
                    return false;
                }
                if($("#linkman").val()==""){
                    $.Huimodalalert('请填写收件人',2000);
                    return false;
                }
                if($("#linkman").val().length>10){
                    $.Huimodalalert('收件人最大长度10',2000);
                    return false;
                }
                var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                if(pattern.test(invoice_titles)){
                    $.Huimodalalert('收件人不能输入特殊字符',2000);
                    return false;
                }
                if($("#officePhone").val()==""){
                    $.Huimodalalert('请填写联系方式',2000);
                    return false;
                }
                if($("#officePhone").val().length>11){
                    $.Huimodalalert('联系方式最大长度11',2000);
                    return false;
                }
                   var regString1 = /[a-zA-Z]+/; 
                var regNumber1 = /.*[\u4e00-\u9fa5]+.*$/;
                var regString2 = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                if (regString1.test($("#officePhone").val()) || regNumber1.test($("#officePhone").val()) || regString2.test($("#officePhone").val())) {
                    $.Huimodalalert('联系方式只能输入数字',2000);
                    return false;
                }
                //普通
                informationdata={
                    "order_id_list":[sessionStorage.getItem("supplementOrderid")],//订单号
                    "invoice_title":invoice_titles,//发票抬头&单位名称
                    "taxpayer_identify_num":taxpayer_identify_nums,//纳税人识别号
                    "register_address":"",//注册地址
                    "register_phone":"",//注册电话
                    "open_bank":"",//开户银行
                    "bank_account":"",//银行账户
                    "invoice_remark":"",//备注
                    "crm_invoice_id":crm_invoice_ids,//开票客户编码
                    "invoice_type":20,//发票类型:10=>增值税;20=>普税
                    "member_id":supplementmemberid,
                    "login_account":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                    //邮寄地址
                    "province_name":$("#getProvinces option:selected").html(),//省
                    "province_code":$("#getProvinces option:selected").val(),//
                    "province":$("#getProvinces option:selected").attr("data-id"),//
                    "city_name":$("#getCitys option:selected").html(),//市
                    "city_code":$("#getCitys option:selected").val(),//
                    "city":$("#getCitys option:selected").attr("data-id"),//
                    "area_name":$("#getAreas option:selected").html(),//区
                    "area_code":$("#getAreas option:selected").val(),//
                    "area":$("#getAreas option:selected").attr("data-id"),//
                    "town_name":$("#getCounty option:selected").html(),//县
                    "town_code":$("#getCounty option:selected").val(),//
                    "town":$("#getCounty option:selected").attr("data-id"),//
                    "detail_address":$("#detailAddress").val(),//详细地址
                    "received_name":$("#linkman").val(),//收件人
                    "received_phone":$("#officePhone").val(),//联系方式
                }
            }else {
                if (distinguishs==10) {
                    if($("#reg_address").val()==""){
                        $.Huimodalalert('请填写注册地址',2000);
                        return false;
                    }
                    if($("#reg_address").val().length>50){
                        $.Huimodalalert('注册地址最大长度50',2000);
                        return false;
                    }
                    var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                    if(pattern.test($("#reg_address").val())){
                        $.Huimodalalert('注册地址不能输入特殊字符',2000);
                        return false;
                    }
                    if($("#reg_telephone").val()==""){
                        $.Huimodalalert('请填写注册电话',2000);
                        return false;
                    }
                    if($("#reg_telephone").val().length>11){
                        $.Huimodalalert('注册电话最大长度11',2000);
                        return false;
                    }
                    var regString1 = /[a-zA-Z]+/;
                    var regNumber1 = /.*[\u4e00-\u9fa5]+.*$/;
                    var regString2 = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                    if (regString1.test($("#reg_telephone").val()) || regNumber1.test($("#reg_telephone").val()) || regString2.test($("#reg_telephone").val())) {
                        $.Huimodalalert('注册电话只能输入数字',2000);
                        return false;
                    }

                    if($("#open_account_bank").val()==""){
                        $.Huimodalalert('请填写开户银行',2000);
                        return false;
                    }
                    if($("#open_account_bank").val().length>50){
                        $.Huimodalalert('开户银行最大长度50',2000);
                        return false;
                    }
                    var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                    if(pattern.test($("#open_account_bank").val())){
                        $.Huimodalalert('开户银行不能输入特殊字符',2000);
                        return false;
                    }
                    if($("#bank_account").val()==""){
                        $.Huimodalalert('请填写银行账户',2000);
                        return false;
                    }
                    if($("#bank_account").val().length>50){
                        $.Huimodalalert('银行账户最大长度50',2000);
                        return false;
                    }
                    var regString1 = /[a-zA-Z]+/;
                    var regNumber1 = /.*[\u4e00-\u9fa5]+.*$/;
                    var regString2 = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                    if (regString1.test($("#bank_account").val()) || regNumber1.test($("#bank_account").val()) || regString2.test($("#bank_account").val())) {
                        $.Huimodalalert('银行账户只能输入数字',2000);
                        return false;
                    }

                }else {
                    if($("#comfirmRemark").val().length>200){
                        $.Huimodalalert('备注信息最大长度200',2000);
                        return false;
                    }
                }
                if($("#getProvinces option:selected").attr("data-id")==""){
                    $.Huimodalalert('请填写邮寄区域',2000);
                    return false;
                }
                if($("#getCitys option:selected").attr("data-id")==""){
                    $.Huimodalalert('请填写邮寄区域',2000);
                    return false;
                }
                if($("#getAreas option:selected").attr("data-id")==""){
                    $.Huimodalalert('请填写邮寄区域',2000);
                    return false;
                }
                if($("#getCounty").css("display")!="none"){
                    if($("#getCounty option:selected").attr("data-id")==""){
                        $.Huimodalalert('请填写邮寄区域',2000);
                        return false;
                    }
                }
                if($("#detailAddress").val()==""){
                    $.Huimodalalert('请填写详细地址',2000);
                    return false;
                }
                if($("#detailAddress").val().length>50){
                    $.Huimodalalert('详细地址最大长度50',2000);
                    return false;
                }
                if($("#linkman").val()==""){
                    $.Huimodalalert('请填写收件人',2000);
                    return false;
                }
                if($("#linkman").val().length>10){
                    $.Huimodalalert('收件人最大长度10',2000);
                    return false;
                }
                var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                if(pattern.test(invoice_titles)){
                    $.Huimodalalert('收件人不能输入特殊字符',2000);
                    return false;
                }
                if($("#officePhone").val()==""){
                    $.Huimodalalert('请填写联系方式',2000);
                    return false;
                }
                if($("#officePhone").val().length>11){
                    $.Huimodalalert('联系方式最大长度11',2000);
                    return false;
                }
                var regString1 = /[a-zA-Z]+/;
                var regNumber1 = /.*[\u4e00-\u9fa5]+.*$/;
                var regString2 = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>《》/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                if (regString1.test($("#officePhone").val()) || regNumber1.test($("#officePhone").val()) || regString2.test($("#officePhone").val())) {
                    $.Huimodalalert('联系方式只能输入数字',2000);
                    return false;
                }
                //增值税
                informationdata={
                    "order_id_list":[sessionStorage.getItem("supplementOrderid")],//订单号
                    "invoice_title":$("#company_name").val(),//发票抬头&单位名称
                    "taxpayer_identify_num":$("#taxpayer_codes").val(),//纳税人识别号
                    "register_address":$("#reg_address").val(),//注册地址
                    "register_phone":$("#reg_telephone").val(),//注册电话
                    "open_bank":$("#open_account_bank").val(),//开户银行
                    "bank_account":$("#bank_account").val(),//银行账户
                    "invoice_remark":$("#comfirmRemark").val(),//备注
                    "crm_invoice_id":$("#crm_invoice_id").val(),//开票客户编码
                    "invoice_type":10,//发票类型:10=>增值税;20=>普税
                    "member_id":supplementmemberid,
                    "login_account":JSON.parse(decodeURIComponent(web.readCookie("loginData"))).user.name,
                    //邮寄地址
                    "province_name":$("#getProvinces option:selected").html(),//省
                    "province_code":$("#getProvinces option:selected").val(),//
                    "province":$("#getProvinces option:selected").attr("data-id"),//
                    "city_name":$("#getCitys option:selected").html(),//市
                    "city_code":$("#getCitys option:selected").val(),//
                    "city":$("#getCitys option:selected").attr("data-id"),//
                    "area_name":$("#getAreas option:selected").html(),//区
                    "area_code":$("#getAreas option:selected").val(),//
                    "area":$("#getAreas option:selected").attr("data-id"),//
                    "town_name":$("#getCounty option:selected").html(),//县
                    "town_code":$("#getCounty option:selected").val(),//
                    "town":$("#getCounty option:selected").attr("data-id"),//
                    "detail_address":$("#detailAddress").val(),//详细地址
                    "received_name":$("#linkman").val(),//收件人
                    "received_phone":$("#officePhone").val(),//联系方式
                }
            }
    $.ajax({
        url:root.orderInter.makeUpInvoiceByCustomerService,
        cache: false,  //禁用缓存
        type: "POST",
        dataType:'json',
        contentType: "application/json",
        data: JSON.stringify(informationdata),
        success: function (data) {
            if(data.errorCode==0){
                if(stare=="发票"){
                    layer.msg("提交成功",{icon: 6,time:2000},function () {
                        setTimeout(function () {
                            window.parent.querysupplementaryInvoiceall();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        })
                    });
                }else {
                    layer.msg("提交成功",{icon: 6,time:2000},function () {
                        setTimeout(function () {
                            window.parent.parent.querysupplementaryInvoiceall();
                            var index = parent.parent.layer.getFrameIndex(window.parent.name);
                            parent.parent.layer.close(index);
                        })
                    });
                }



            }else {
                $.Huimodalalert(data.msg,2000);
            }

        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    });
}
function onunm(e){
    var c=$(e);
    if(/[^\d]/.test(c.val())){//替换非数字字符
        var temp_amount=c.val().replace(/[^\d]/g,'');
        c.val(temp_amount);
    }

};